package com.tdw.eurekaclient.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
	private static final Logger logger = LoggerFactory.getLogger(HelloController.class);

	@Autowired
	private AmqpTemplate rabbitTemplate;
	
	@RequestMapping(value="/hello")
	public String hello(HttpServletRequest request){
		String context = request.getParameter("context");
		if("".equals(context) || null == context)
			return "context is empty";
		logger.info("send msg to mq , msg={}",context);
		rabbitTemplate.convertAndSend("hello", context);
		return "ok";
	}
	
	
	 
}
